<template>
    <div class="recent" v-show="recentactive.length>0">
        <h5>近期活动</h5>
        <ul>
            <li v-for="(item, index) in recentactive"><a ca="天天礼包_最近活动$" :href="item.activityUrl"><img :src="item.imgUrl" alt=""></a></li>

        </ul>
    </div>
</template>
<script>
    import common from "../../assets/js/common.js";
    import qs from 'querystring';
    import url  from 'url';
    import {Toast} from 'mint-ui';
    export default {
        data(){
            return {
                currentCity:'',
                recentactive:[]

            };
        },
        created(){
            var _this = this;
            var latLon = this.getParam();
            //var currentCity = _this.currentCity = decodeURIComponent(latLon.cityName);
            var currentCity = _this.currentCity = latLon.cityName;
            //console.log("currentCity:"+ currentCity);
            //获取普通券数据 /daily/list/0.htm
            _this.$http.get(common.isdev() + '/cxb/rmhd/index.shtml', {}).then(function(data){
                var data = _this.parseData(data.body);
                console.log("==data==");
                console.log(data);
                currentCity = currentCity.replace('市','');
                _this.recentactive = data.result[currentCity];
            }, function( err) {
                Toast('请求数据失败');
            });
        },
        mounted(){
            this.$nextTick(function(){
                common.ANA_AnalyticsScan();
            });
        },
        methods:{
            getParam(){
                var tar = url.parse(window.location.href).query,tmpObj = qs.parse(decodeURIComponent(tar));
                return tmpObj;
            },
            parseData: function(data) {
                var _data;
                if (!data) return data;
                try{
                    _data = JSON.parse(data);
                }catch(e){
                    _data = data;
                }
                return _data;
            }
        }

    }

</script>

<style lang="scss" scoped> 
@import '../../assets/css/common.scss';    
    
@function rem($px){
  @return $px / 10 * 1rem;
}
html,body{
    height:100%;
}
body {
    background: #f4f4f4;
}
.recent{
    padding:0 rem(10);
    h5{
        margin-bottom:rem(17);
        font-size:rem(17);
        color:#243742;
        font-weight:bold;
    }
    li{
       margin-bottom:rem(10); 
       img{
        width:100%;
       }
    }
}
</style>

